package com.ruoyi.tools.util.check;

import java.util.regex.Pattern;

public class StrCheckUtil {

    /**
     * 验证正整数
     * @return true为空 false不为空
     */
    public static boolean isInteger(String str) {
        if (str == null || "".equals(str.trim())) {
            return true;
        }
        try {
            Integer.parseInt(str);
        } catch (NumberFormatException e) {
            return true;
        }
        return false;
    }


    /**
     * 验证邮箱格式
     * @param email 邮箱
     * @return true false
     */
    public static boolean emailCheck(String email) {
        //正则验证邮箱格式
        if (email == null || "".equals(email)) {
            return true;
        }
        String emailMatcher="[a-zA-Z0-9]+@[a-zA-Z0-9]+\\.[a-zA-Z0-9]+";
        boolean isMatch = Pattern.matches(emailMatcher,email);
        return !isMatch;
    }

    //验证11位手机号
    public static boolean phoneCheck(String phone) {
//        if (phone == null || "".equals(phone.trim())) {
//            return true;
//        }
//        String phoneMatcher="^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$";
//        boolean isMatch = Pattern.matches(phoneMatcher,phone);
//        return !isMatch;
        return false;
    }

    public static void main(String[] args) {

//        String email = "anpchexample.com";
//        boolean b = emailCheck(email);
    }


}
